package com.xiang.producer;

import com.xiang.RabbitmqApplication;
import com.xiang.config.RabbitMqSimpleConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * 简单队列生产者
 *
 * @author: xiangtianlei
 * @Date: 2022-9-8
 */
@SpringBootTest(classes = RabbitmqApplication.class)
@RunWith(SpringRunner.class)
public class ProducerSimplerTest {
    Logger log = LoggerFactory.getLogger(ProducerSimplerTest.class);

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void monitorSimpleQueue() {
        for (int i = 0; i < 100; i++) {
            log.info("发送的数字为：" + i);
            rabbitTemplate.convertAndSend(RabbitMqSimpleConfig.SIMPLE_QUEUE, "简单队列模式" + i);
        }
    }

}
